/*
 * Copyright (c) 2023, Texas Instruments Incorporated - http://www.ti.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 *  ============ ti_msp_dl_config.h =============
 *  Configured MSPM0 DriverLib module declarations
 *
 *  DO NOT EDIT - This file is generated for the MSPM0G350X
 *  by the SysConfig tool.
 */
#ifndef ti_msp_dl_config_h
#define ti_msp_dl_config_h

#define CONFIG_MSPM0G350X

#if defined(__ti_version__) || defined(__TI_COMPILER_VERSION__)
#define SYSCONFIG_WEAK __attribute__((weak))
#elif defined(__IAR_SYSTEMS_ICC__)
#define SYSCONFIG_WEAK __weak
#elif defined(__GNUC__)
#define SYSCONFIG_WEAK __attribute__((weak))
#endif

#include <ti/devices/msp/msp.h>
#include <ti/driverlib/driverlib.h>
#include <ti/driverlib/m0p/dl_core.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 *  ======== SYSCFG_DL_init ========
 *  Perform all required MSP DL initialization
 *
 *  This function should be called once at a point before any use of
 *  MSP DL.
 */


/* clang-format off */

#define POWER_STARTUP_DELAY                                                (16)


#define GPIO_HFXT_PORT                                                     GPIOA
#define GPIO_HFXIN_PIN                                             DL_GPIO_PIN_5
#define GPIO_HFXIN_IOMUX                                         (IOMUX_PINCM10)
#define GPIO_HFXOUT_PIN                                            DL_GPIO_PIN_6
#define GPIO_HFXOUT_IOMUX                                        (IOMUX_PINCM11)
#define CPUCLK_FREQ                                                     80000000



/* Defines for PWM_MOTOR */
#define PWM_MOTOR_INST                                                     TIMA0
#define PWM_MOTOR_INST_IRQHandler                               TIMA0_IRQHandler
#define PWM_MOTOR_INST_INT_IRQN                                 (TIMA0_INT_IRQn)
#define PWM_MOTOR_INST_CLK_FREQ                                         10000000
/* GPIO defines for channel 0 */
#define GPIO_PWM_MOTOR_C0_PORT                                             GPIOA
#define GPIO_PWM_MOTOR_C0_PIN                                     DL_GPIO_PIN_21
#define GPIO_PWM_MOTOR_C0_IOMUX                                  (IOMUX_PINCM46)
#define GPIO_PWM_MOTOR_C0_IOMUX_FUNC                 IOMUX_PINCM46_PF_TIMA0_CCP0
#define GPIO_PWM_MOTOR_C0_IDX                                DL_TIMER_CC_0_INDEX
/* GPIO defines for channel 1 */
#define GPIO_PWM_MOTOR_C1_PORT                                             GPIOA
#define GPIO_PWM_MOTOR_C1_PIN                                      DL_GPIO_PIN_7
#define GPIO_PWM_MOTOR_C1_IOMUX                                  (IOMUX_PINCM14)
#define GPIO_PWM_MOTOR_C1_IOMUX_FUNC                 IOMUX_PINCM14_PF_TIMA0_CCP1
#define GPIO_PWM_MOTOR_C1_IDX                                DL_TIMER_CC_1_INDEX



/* Defines for TIMER_0 */
#define TIMER_0_INST                                                     (TIMA1)
#define TIMER_0_INST_IRQHandler                                 TIMA1_IRQHandler
#define TIMER_0_INST_INT_IRQN                                   (TIMA1_INT_IRQn)
#define TIMER_0_INST_LOAD_VALUE                                           (999U)



/* Defines for UART_0 */
#define UART_0_INST                                                        UART0
#define UART_0_INST_IRQHandler                                  UART0_IRQHandler
#define UART_0_INST_INT_IRQN                                      UART0_INT_IRQn
#define GPIO_UART_0_RX_PORT                                                GPIOA
#define GPIO_UART_0_TX_PORT                                                GPIOA
#define GPIO_UART_0_RX_PIN                                        DL_GPIO_PIN_11
#define GPIO_UART_0_TX_PIN                                        DL_GPIO_PIN_10
#define GPIO_UART_0_IOMUX_RX                                     (IOMUX_PINCM22)
#define GPIO_UART_0_IOMUX_TX                                     (IOMUX_PINCM21)
#define GPIO_UART_0_IOMUX_RX_FUNC                      IOMUX_PINCM22_PF_UART0_RX
#define GPIO_UART_0_IOMUX_TX_FUNC                      IOMUX_PINCM21_PF_UART0_TX
#define UART_0_BAUD_RATE                                                (115200)
#define UART_0_IBRD_40_MHZ_115200_BAUD                                      (21)
#define UART_0_FBRD_40_MHZ_115200_BAUD                                      (45)
/* Defines for IMU */
#define IMU_INST                                                           UART3
#define IMU_INST_IRQHandler                                     UART3_IRQHandler
#define IMU_INST_INT_IRQN                                         UART3_INT_IRQn
#define GPIO_IMU_RX_PORT                                                   GPIOB
#define GPIO_IMU_TX_PORT                                                   GPIOB
#define GPIO_IMU_RX_PIN                                            DL_GPIO_PIN_3
#define GPIO_IMU_TX_PIN                                            DL_GPIO_PIN_2
#define GPIO_IMU_IOMUX_RX                                        (IOMUX_PINCM16)
#define GPIO_IMU_IOMUX_TX                                        (IOMUX_PINCM15)
#define GPIO_IMU_IOMUX_RX_FUNC                         IOMUX_PINCM16_PF_UART3_RX
#define GPIO_IMU_IOMUX_TX_FUNC                         IOMUX_PINCM15_PF_UART3_TX
#define IMU_BAUD_RATE                                                   (115200)
#define IMU_IBRD_80_MHZ_115200_BAUD                                         (43)
#define IMU_FBRD_80_MHZ_115200_BAUD                                         (26)





/* Defines for DMA_CH0 */
#define DMA_CH0_CHAN_ID                                                      (0)
#define UART_0_INST_DMA_TRIGGER                              (DMA_UART0_TX_TRIG)



/* Port definition for Pin Group STBY */
#define STBY_PORT                                                        (GPIOA)

/* Defines for PIN_STBY: GPIOA.24 with pinCMx 54 on package pin 44 */
#define STBY_PIN_STBY_PIN                                       (DL_GPIO_PIN_24)
#define STBY_PIN_STBY_IOMUX                                      (IOMUX_PINCM54)
/* Port definition for Pin Group GRP_Trace */
#define GRP_Trace_PORT                                                   (GPIOA)

/* Defines for PIN_1: GPIOA.1 with pinCMx 2 on package pin 2 */
#define GRP_Trace_PIN_1_PIN                                      (DL_GPIO_PIN_1)
#define GRP_Trace_PIN_1_IOMUX                                     (IOMUX_PINCM2)
/* Defines for PIN_2: GPIOA.28 with pinCMx 3 on package pin 3 */
#define GRP_Trace_PIN_2_PIN                                     (DL_GPIO_PIN_28)
#define GRP_Trace_PIN_2_IOMUX                                     (IOMUX_PINCM3)
/* Defines for PIN_3: GPIOA.31 with pinCMx 6 on package pin 5 */
#define GRP_Trace_PIN_3_PIN                                     (DL_GPIO_PIN_31)
#define GRP_Trace_PIN_3_IOMUX                                     (IOMUX_PINCM6)
/* Defines for PIN_4: GPIOA.3 with pinCMx 8 on package pin 9 */
#define GRP_Trace_PIN_4_PIN                                      (DL_GPIO_PIN_3)
#define GRP_Trace_PIN_4_IOMUX                                     (IOMUX_PINCM8)
/* Defines for PIN_5: GPIOA.4 with pinCMx 9 on package pin 10 */
#define GRP_Trace_PIN_5_PIN                                      (DL_GPIO_PIN_4)
#define GRP_Trace_PIN_5_IOMUX                                     (IOMUX_PINCM9)
/* Defines for PIN_6: GPIOA.23 with pinCMx 53 on package pin 43 */
#define GRP_Trace_PIN_6_PIN                                     (DL_GPIO_PIN_23)
#define GRP_Trace_PIN_6_IOMUX                                    (IOMUX_PINCM53)
/* Defines for PIN_7: GPIOA.25 with pinCMx 55 on package pin 45 */
#define GRP_Trace_PIN_7_PIN                                     (DL_GPIO_PIN_25)
#define GRP_Trace_PIN_7_IOMUX                                    (IOMUX_PINCM55)
/* Port definition for Pin Group ENCODER_L */
#define ENCODER_L_PORT                                                   (GPIOA)

/* Defines for L_A: GPIOA.15 with pinCMx 37 on package pin 30 */
// groups represented: ["ENCODR_R","ENCODER_L"]
// pins affected: ["R_A","R_B","L_A","L_B"]
#define GPIO_MULTIPLE_GPIOA_INT_IRQN                            (GPIOA_INT_IRQn)
#define GPIO_MULTIPLE_GPIOA_INT_IIDX            (DL_INTERRUPT_GROUP1_IIDX_GPIOA)
#define ENCODER_L_L_A_IIDX                                  (DL_GPIO_IIDX_DIO15)
#define ENCODER_L_L_A_PIN                                       (DL_GPIO_PIN_15)
#define ENCODER_L_L_A_IOMUX                                      (IOMUX_PINCM37)
/* Defines for L_B: GPIOA.16 with pinCMx 38 on package pin 31 */
#define ENCODER_L_L_B_IIDX                                  (DL_GPIO_IIDX_DIO16)
#define ENCODER_L_L_B_PIN                                       (DL_GPIO_PIN_16)
#define ENCODER_L_L_B_IOMUX                                      (IOMUX_PINCM38)
/* Port definition for Pin Group GPIO_KEY */
#define GPIO_KEY_PORT                                                    (GPIOB)

/* Defines for KEY1: GPIOB.14 with pinCMx 31 on package pin 24 */
#define GPIO_KEY_KEY1_PIN                                       (DL_GPIO_PIN_14)
#define GPIO_KEY_KEY1_IOMUX                                      (IOMUX_PINCM31)
/* Defines for KEY2: GPIOB.9 with pinCMx 26 on package pin 23 */
#define GPIO_KEY_KEY2_PIN                                        (DL_GPIO_PIN_9)
#define GPIO_KEY_KEY2_IOMUX                                      (IOMUX_PINCM26)
/* Defines for KEY3: GPIOB.8 with pinCMx 25 on package pin 22 */
#define GPIO_KEY_KEY3_PIN                                        (DL_GPIO_PIN_8)
#define GPIO_KEY_KEY3_IOMUX                                      (IOMUX_PINCM25)
/* Defines for KEY4: GPIOB.7 with pinCMx 24 on package pin 21 */
#define GPIO_KEY_KEY4_PIN                                        (DL_GPIO_PIN_7)
#define GPIO_KEY_KEY4_IOMUX                                      (IOMUX_PINCM24)
/* Defines for KEY5: GPIOB.6 with pinCMx 23 on package pin 20 */
#define GPIO_KEY_KEY5_PIN                                        (DL_GPIO_PIN_6)
#define GPIO_KEY_KEY5_IOMUX                                      (IOMUX_PINCM23)
/* Port definition for Pin Group ENCODR_R */
#define ENCODR_R_PORT                                                    (GPIOA)

/* Defines for R_A: GPIOA.17 with pinCMx 39 on package pin 32 */
#define ENCODR_R_R_A_IIDX                                   (DL_GPIO_IIDX_DIO17)
#define ENCODR_R_R_A_PIN                                        (DL_GPIO_PIN_17)
#define ENCODR_R_R_A_IOMUX                                       (IOMUX_PINCM39)
/* Defines for R_B: GPIOA.22 with pinCMx 47 on package pin 40 */
#define ENCODR_R_R_B_IIDX                                   (DL_GPIO_IIDX_DIO22)
#define ENCODR_R_R_B_PIN                                        (DL_GPIO_PIN_22)
#define ENCODR_R_R_B_IOMUX                                       (IOMUX_PINCM47)
/* Defines for PIN_SWITCH: GPIOA.0 with pinCMx 1 on package pin 1 */
#define GPIO_GRP_0_PIN_SWITCH_PORT                                       (GPIOA)
#define GPIO_GRP_0_PIN_SWITCH_PIN                                (DL_GPIO_PIN_0)
#define GPIO_GRP_0_PIN_SWITCH_IOMUX                               (IOMUX_PINCM1)
/* Defines for PIN_LED_BIBI: GPIOB.15 with pinCMx 32 on package pin 25 */
#define GPIO_GRP_0_PIN_LED_BIBI_PORT                                     (GPIOB)
#define GPIO_GRP_0_PIN_LED_BIBI_PIN                             (DL_GPIO_PIN_15)
#define GPIO_GRP_0_PIN_LED_BIBI_IOMUX                            (IOMUX_PINCM32)
/* Defines for PIN_BIBI: GPIOB.17 with pinCMx 43 on package pin 36 */
#define GPIO_GRP_0_PIN_BIBI_PORT                                         (GPIOB)
#define GPIO_GRP_0_PIN_BIBI_PIN                                 (DL_GPIO_PIN_17)
#define GPIO_GRP_0_PIN_BIBI_IOMUX                                (IOMUX_PINCM43)





/* clang-format on */

void SYSCFG_DL_init(void);
void SYSCFG_DL_initPower(void);
void SYSCFG_DL_GPIO_init(void);
void SYSCFG_DL_SYSCTL_init(void);
void SYSCFG_DL_PWM_MOTOR_init(void);
void SYSCFG_DL_TIMER_0_init(void);
void SYSCFG_DL_UART_0_init(void);
void SYSCFG_DL_IMU_init(void);
void SYSCFG_DL_DMA_init(void);

void SYSCFG_DL_SYSTICK_init(void);


bool SYSCFG_DL_saveConfiguration(void);
bool SYSCFG_DL_restoreConfiguration(void);

#ifdef __cplusplus
}
#endif

#endif /* ti_msp_dl_config_h */
